<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <title>与 {{$user_name}} 的纸条 - {{Session::get('name')}}的个人中心</title>
    <meta name="viewport" content="width=device-width, height=device-height, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0">
    <meta name="format-detection" content="telephone=no">
    <meta name="author" content="夜读书">
    <meta name="description" content="夜读书。">
    <meta name="keywords" content="夜读书">
    <link rel="stylesheet" href="{{ asset('/bootstrap-3.3.5-dist/css/bootstrap.min.css') }}">
    <link rel="stylesheet" href="{{ asset('/style/css/mobile.css') }}">    
    <link rel="stylesheet" href="{{ asset('/style/css/mobile_zhitiao.css') }}">   
    <script src="{{ asset('/scripts/jquery/jquery-1.11.3.min.js') }}"></script>
    <script src="{{ asset('/bootstrap-3.3.5-dist/js/bootstrap.min.js') }}"></script>    
    <script type="text/javascript" charset="utf-8" src="{{url('editor/ueditor1_4_3_3/ueditor.config.js')}}"></script>
    <script type="text/javascript" charset="utf-8" src="{{url('editor/ueditor1_4_3_3/ueditor.all.js')}}"> </script>
    <script type="text/javascript" charset="utf-8" src="{{url('editor/ueditor1_4_3_3/lang/zh-cn/zh-cn.js')}}"></script>  
</head>
<body>
@include('mobile.nav')
<div id="index">
    <div class="docs-wrapper zhitiao">
    <div class="title" style="font-size: 16px;">与 {{$user_name}} 的纸条 (共{{$message_count}}条)</div>    
    <form name="form" class="" action="" method="post">
        <input type="hidden" name="_token" value="{{ csrf_token() }}" />
        <div class="msgs">
            <div class="zhitiao-send">
                <script id="fazhitiao" name="fazhitiao" type="text/plain">请输入内容，最多250字</script>
            </div>
            <div class="">
                <span class="tishi"></span>
                <span class="ui positive submit button">发送纸条</span>
            </div>
        </div>        
        <div style="clear:both;"></div>
    </form>
    @if($zhitiaos != null)
    @foreach($zhitiaos as $zhitiao)
    <div class="item">
        <a class="face" href="{{url('mobile/uhome/'.$zhitiao->fa_id)}}">
            <div class="avatar">
                @if($zhitiao->sender_image!="")
                    <img src="{{url($zhitiao->sender_image)}}">
                @else
                    <img src="{{url('usersface/default/avatar-min.png')}}">
                @endif
            </div>
        </a>
        <div class="content">
            <a class="name" href="{{url('mobile/uhome/'.$zhitiao->fa_id)}}">{{$zhitiao->sender_name}}</a>
            <div class="description">{!! $zhitiao->content->content !!}</div>
            <div class="extra">
                <span class="delete"><a href="{{url('mobile/zhitiao/delmsg/'.$zhitiao->id)}}" onclick="javascript:return p_del()">删除</a></span>
                <span class="time">{{date('Y-m-d H:i',$zhitiao->send_time)}}</span>
            </div>
        </div>
    </div>
    @endforeach
    @else
        <div class="" style="font-size: 16px;">暂无纸条</div>
    @endif
</div>
<script type="text/javascript">
    //实例化编辑器
    var ue = UE.getEditor('fazhitiao',{
        wordCount: true, //开启字数统计
        elementPathEnabled: false,//是否启用元素路径，默认是显示
        maximumWords: 250,       //允许的最大字符数
        initialContent: '',    //初始化编辑器的内容,也可以通过textarea/script给值，看官网例子
        //autoClearinitialContent: true, //是否自动清除编辑器初始内容，注意：如果focus属性设置为true,这个也为真，那么编辑器一上来就会触发导致初始化的内容看不到了
        pasteplain: true,  //是否默认为纯文本粘贴。false为不使用纯文本粘贴，true为使用纯文本粘贴
        enableContextMenu: false, //关闭右键菜单功能
        //imageUrlPrefix: "http://localhost:4176", /* 图片访问路径前缀 */
        //imagePathFormat: "/UploadFiles/{yyyy}{mm}{dd}/{time}{rand:6}",/* 上传保存路径,可以自定义保存路径和文件名格式 */
        //urlTarget: "Email",
        //initialFrameWidth: 500, //初始化宽度
        initialFrameHeight: 100, //初始化高度
        autoHeightEnabled: true, //关闭高度自适应
        enableAutoSave: false //禁止自动保存
        ,toolbars: []
    });

    ue.ready(function() {
        //默认显示内容
        ue.setContent('<p style="color:silver">请输入内容，最多250字</p>');
        //文本框获取焦点时清空默认显示的内容
        ue.addListener("focus", function(){
            if(UE.getEditor('fazhitiao').getContentTxt() == '请输入内容，最多250字'){
                ue.setContent('');
            }
        });
        //文本框失去焦点时,若内容为空则显示默认显示的内容
        ue.addListener("blur", function(){
            if(!ue.getContent()){
                ue.setContent('<p style="color:silver">请输入内容，最多250字</p>');
            }
        });
    }); 

    $(document).ready(function(){
        $(".submit").click(function(){
            if(!UE.getEditor('fazhitiao').hasContents() || UE.getEditor('fazhitiao').getContentTxt() == '请输入内容，最多250字')
            {
                $(".tishi").html("<font color='red'>请输入纸条内容。</font>");
                UE.getEditor('fazhitiao').focus();
            }
            else
            {
                form.submit();
            }
        });
    });     
</script>
<script language="javascript">
    function p_del() {
        var msg= "确定删除本条信息？\n\n";
        if (confirm(msg)==true) {
            return true;
        }
        else
        {
            return false;
        }
    }
</script>
</div>

@include('mobile.footer')
</body>
</html>